#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)
Dummy::Application.load_tasks

require 'rspec/core/rake_task'
require "cucumber/rake/task"

Cucumber::Rake::Task.new(:cucumber) do |task|
  task.cucumber_opts = ["features --format pretty --backtrace"]
end

RSpec::Core::RakeTask.new(:spec)
task :default => :spec

task :jasmine do
  system("jasmine-headless-webkit --color")
end

task :travis do
  ["rspec spec", "rake cucumber", "rake jasmine"].each do |cmd|
    puts "Starting to run #{cmd}..."
    system("export DISPLAY=:99.0 && bundle exec #{cmd}")
    raise "#{cmd} failed!" unless $?.exitstatus == 0
  end
end

task :default => :travis
